//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package 力扣.题库.未分类;

import java.util.HashMap;
import java.util.Map;

public class demo_1128 {
    public demo_1128() {
    }

    public int numEquivDominoPairs(int[][] dominoes) {
        HashMap<Map.Entry<Integer, Integer>, Integer> map = new HashMap();
        int n = dominoes.length;

        for(int[] dominoe : dominoes) {
            Map.Entry<Integer, Integer> entry1 = Map.entry(dominoe[0], dominoe[1]);
            Map.Entry<Integer, Integer> entry2 = Map.entry(dominoe[1], dominoe[0]);
            if (map.get(entry1) != null) {
                map.put(entry1, (Integer)map.get(entry1) + 1);
            } else if (map.get(entry2) != null) {
                map.put(entry2, (Integer)map.get(entry2) + 1);
            } else {
                map.put(entry1, 1);
            }
        }

        int count = 0;

        for(Map.Entry<Map.Entry<Integer, Integer>, Integer> entry : map.entrySet()) {
            int value = (Integer)entry.getValue();
            if (value >= 2) {
                count += value * (value - 1) / 2;
            }
        }

        return count;
    }
}
